//
//  BaseTableViewController.swift
//  WeiBo(Swift)
//
//  Created by 周成龙 on 16/9/21.
//  Copyright © 2016年 ZCL. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {
    
    var visitorView: VisitorView?
    
    let isLogin = UserAccount.isLogin()
    override func loadView() {
        isLogin ? super.loadView() : setupVisitorView()
    }
    
    private func setupVisitorView() {
        visitorView = VisitorView.visitorView();
        view = visitorView
        
        visitorView?.loginButton.addTarget(self, action: #selector(BaseTableViewController.loginButtonClick), for: UIControlEvents.touchUpInside)
        visitorView?.resignButton.addTarget(self, action: #selector(BaseTableViewController.resignButtonClick), for: UIControlEvents.touchUpInside)
    }
    
    @objc func loginButtonClick() {
        let sb = UIStoryboard(name: "OAuth", bundle: nil)
        guard let oauth = sb.instantiateInitialViewController() else {
            return
        }
        present(oauth, animated: true, completion: nil)
    }
    
    @objc func resignButtonClick() {
        ZLog(message: "===")
    }
    
    
    override func viewDidLoad() {
        
    }
}
